#include "product.h"

Product::Product(QString _productName, QString _unit, float _quantity){
    productName=_productName;
    unit=_unit;
    quantity = _quantity;
}

Product::Product(){
    productName="";
    unit="";
    quantity = 0.0;
}

QString Product::getName(){
    return productName;
}

int Product::countSuppliers(){
    return suppliers.count();
}

QString Product::getUnit(){
    return unit;
}

float Product::getQuantity(){
    return quantity;
}

Supplier Product::getSupplier(int i){
    Supplier empty("",9999,0,0);
    if(i >= 0 && i< suppliers.count())
        return suppliers[i];
    return empty;
}

bool Product::addSupplier(QString _supplierName, float _cost, int _productionTime, int _quantityAvalaiblePerDay){
    Supplier toAdd(_supplierName, _cost,  _productionTime, _quantityAvalaiblePerDay );
    suppliers.push_back(toAdd);
    return true;
}

bool Product::removeSupplier(int i){
    if(i<0||i>=suppliers.count())
        return false;
    suppliers.remove(i);
    return true;

}

